package com.gec.system.controller;

import com.gec.model.system.SysCategory;
import com.gec.system.common.Result;
import com.gec.system.service.SysCategoryService;
import com.gec.system.service.SysMovieService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
//http://localhost:8085/admin/system/front/allCategory
@Api(tags = "前台影视管理控制器")
@RestController
@RequestMapping("/admin/system/front")
@CrossOrigin
public class FrontController {
    @Autowired
    private SysCategoryService categoryService;
    @Autowired
    private SysMovieService movieService;

    @ApiOperation("查询所有分类")
    @GetMapping("/allCategory")
    public Result allCategory(){
        List<SysCategory> categories = categoryService.list();
        return Result.ok(categories);
    }

    @ApiOperation("根据分类id查询最新影片分页")
    @GetMapping("/getNewMovieList")
    public Result getNewMovieList(Integer pageNum, Integer pageSize, Long cid){
        return movieService.getNewMovieList(pageNum, pageSize, cid);
    }

    @ApiOperation("在前台根据id查询影片以及播放密钥")
    @GetMapping("/getPlayAuthInFront/{id}")
    public Result getPlayAuthByIdInFront(@PathVariable Long id){
        return movieService.getPlayAuthById(id);
    }



}
